/*
 * ROSA_sem.h
 *
 * Created: 2014-12-03 13:32:52
 *  Author: Andreas Domfors
 */ 


#ifndef ROSA_SEM_H_
#define ROSA_SEM_H_

typedef void *semaphore;

/// Creates and initializes a semaphore at the specified
/// address. The semaphore is available when created.
/// s must point at 
int ROSA_createBinarySemaphore(semaphore *s);

/// Waits for the specified binary semaphore. If (timeout) ticks 
/// pass without the semaphore becoming available, the operation
/// times out.
int ROSA_waitBinarySemaphore(semaphore *s, unsigned int timeout);

/// Signals the specified binary semaphore.
int ROSA_signalBinarySemaphore(semaphore *s);

typedef void *IPCPsemaphore;

/// Creates and initializes an IPCP semaphore at the location s.
/// The semaphore is available when created.
int ROSA_createSemaphoreIPCP(IPCPsemaphore *s, unsigned int ceiling);

/// Waits for the specified IPCP semaphore. If (timeout) ticks
/// pass without the semaphore becoming available, the operation
/// times out.
int ROSA_waitSemaphoreIPCP(IPCPsemaphore *s, unsigned int timeout);

/// Signals the specified IPCP semaphore. The task that calls this must
/// be the last task that successfully waited for the semaphore.
int ROSA_signalSemaphoreIPCP(IPCPsemaphore *s);

#endif /* ROSA_SEM_H_ */